package vno.fux.ui
{
	import vno.fux.character.BaseCharacterView;
	import vno.fux.BasePoint;
	import vno.fux.events.MapEvent;

	public class WalkTarget implements IComponent
	{
		private var _model:WalkTargetModel;
		private var _view:WalkTargetView;
		private var _controller:WalkTargetController;
		public function WalkTarget(id_:uint, resId_:uint)
		{
			_model		= new WalkTargetModel({id:id_,resId:resId_});
			_controller = new WalkTargetController(_model);
			_view		= new WalkTargetView(_model, _controller);
		}

		public function updatePos(pos:BasePoint):void
		{
			_controller.handlePosUpdate(pos);
		}
		public function moveStateHandle(moveState:MapEvent):void
		{
			switch(moveState.type)
			{
				case MapEvent.START_MOVE:
					_view.move();
					_controller.startMove(moveState.start, moveState.end);
					break;
				case MapEvent.END_MOVE:
					_view.stop();
					break;
				case MapEvent.UNREACH:
					_view.cross();
					_controller.handleUnreach(moveState.pos);
					break;
			}
		}
		public function get view():BaseComponentView
		{
			return _view;
		}
	}
}